{% stylesheet %}
.block_blogs .blogs_content {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  grid-column-gap: 30px;
  grid-row-gap: 30px;
}

.block_blogs .blogs_content .blogs_item {
  cursor: pointer;
}

.block_blogs .blogs_content .blogs_item:hover .img_box img {
  transform: scale(1.1);
}

.block_blogs .blogs_content .blogs_item article {
  height: auto;
  width: 100%;
  position: relative;
}

.block_blogs .blogs_content .blogs_item article .img_box {
  overflow: hidden;
}

.block_blogs .blogs_content .blogs_item article .img_box img {
  width: 100%;
  transition: transform .3s;
}

.block_blogs .blogs_content .blogs_item article .text .text_title {
  margin-top: 20px;
}

.block_blogs .blogs_content .blogs_item article .text .text_title h2 {
  font-family: var(--title_font_family);
  font-style: var(--title_font_style);
  font-weight: var(--title_font_weigth);
  letter-spacing: var(--title_letter_spacing);
  line-height: 25px;
}

.block_blogs .blogs_content .blogs_item article .text .text_title h2:hover {
  opacity: 0.8;
}

.block_blogs .blogs_content .blogs_item article .text .time {
  opacity: 0.8;
  margin-top: 16px;
  font-size: 12px;
}

.block_blogs .blogs_content .blogs_item article .text .detail {
  margin-top: 16px;
}

.block_blogs .blogs_content .blogs_left {
  grid-column: span 2;
  color: #fff;
}

@media screen and (min-width: 767px) and (max-width: 1024px) {
  .block_blogs .blogs_content .blogs_left {
    grid-column: span 4;
  }
}

@media screen and (max-width: 767px) {
  .block_blogs .blogs_content .blogs_left {
    grid-column: span 4;
  }
  .block_blogs .blogs_content .blogs_left .detail {
    display: none;
  }
}

.block_blogs .blogs_content .blogs_left article {
  height: auto;
  width: 100%;
  position: relative;
}

.block_blogs .blogs_content .blogs_left article .img_box {
  position: relative;
}

.block_blogs .blogs_content .blogs_left article .img_box img {
  width: 100%;
  object-fit: cover;
}

.block_blogs .blogs_content .blogs_left article .img_box::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(0deg, rgba(33, 28, 28, 0.49) 0%, rgba(33, 28, 28, 0) 136.62%);
}

.block_blogs .blogs_content .blogs_left article .text {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

@media screen and (min-width: 768px) {
  .block_blogs .blogs_content .blogs_left article .text .text_title h2 {
    font-size: var(--title_font_size);
    line-height: 40px;
    font-family: var(--title_font_family);
    font-style: var(--title_font_style);
    font-weight: var(--title_font_weigth);
    letter-spacing: var(--title_letter_spacing);
  }
}

.block_blogs .blogs_content .blogs_left article .text .text_title h2 {
  color: inherit;
}

.block_blogs .blogs_content .blogs_left article .text .text_title h2:hover {
  opacity: 0.8;
}

.block_blogs .blogs_content .blogs_left article .text .time {
  opacity: 0.8;
  margin-top: 16px;
  font-size: 12px;
}

.block_blogs .blogs_content .blogs_left article .text .detail {
  margin-top: 16px;
}

@media screen and (min-width: 767px) and (max-width: 1024px) {
  .block_blogs .blogs_content .blogs_right {
    grid-column: span 2;
  }
}

@media screen and (max-width: 767px) {
  .block_blogs .blogs_content .blogs_right {
    grid-column: span 4;
  }
}

.block_blogs .more {
  display: flex;
  justify-content: center;
  align-items: center;
}

{% endstylesheet %}
{% assign data = section.settings %}
<div class="block_blogs container_wrapper">
    {% include 'title', title: data.block_title,detaile: data.block_detail,textAlgin: data.text_align %}
    <div class="blogs_content">
        {% assign blogs_ids = section.blocks | get_array_values: "blog" | get_array_values: "id" | join: "," %}
        {% if section.blocks.size %}
        {% get_blogs ids={blogs_ids} %}
        {% for block in section.blocks %}
        {% assign id = block.blog.id %}
        {% if blogs[id].size > 1 %}
        {% assign blog = blogs[id] %}
        <div class="blogs_item {% if forloop.first == true %}blogs_left{% else %}blogs_right{% endif %}">
            <article>
               <a href="/blogs/{{ blog.handle }}">
                  <div class="img_box">
                      <img data-sizes="auto" data-src="{{ blog.src }}" src="{{ 'empty_loading.png' | public_asset_abs_url }}"
                          alt="{{ blog.title }}" />
                  </div>
                  <div class="text">
                      <div class="text_title">
                          <h2>
                            {{ blog.title }}
                          </h2>
                      </div>
                      <div class="time" data-date="{{blog.created_at}}" data-format="YYYY-mm-dd">{{ blog.published_at | date: "%Y-%m-%d" }}</div>
                      {% if blog.descript != '' %}
                      <div class="detail">{{ blog.descript }}</div>
                      {% endif %}
                  </div>
                </a>
            </article>
        </div>
        {% else %}
        <div class="blogs_item {% if forloop.first == true %}blogs_left{% else %}blogs_right{% endif %}">
            <article>
              <a href="javascirpt:;">
                <div class="img_box">
                    <img data-sizes="auto" data-src="" src="{{ 'empty.png' | public_asset_abs_url }}"
                        alt="Please select blog" />
                </div>
                <div class="text">
                    <div class="text_title">
                        <h2>
                            Blog Title
                        </h2>
                    </div>
                    <div class="time">February 2022</div>
                    <div class="detail">Linen is one of the most common fabrics available these days, especially for
                        bath and bed fabrics. Discover several facts about it.</div>
                </div>
              </a>
            </article>
        </div>
        {% endif %}
        {% endfor %}
        {% endif %}
    </div>
    <div class="more">
        {% include 'animation_btn', text: data.more_text,btnType: 'secondary_btn', url: '/blogs' %}
    </div>
</div>
{% schema %}
{
	"tag": "",
	"class": "block_blogs",
	"icon": "icon-boke",
	"is_global": false,
	"name": {
		"zh_CN": "博客",
		"en_US": "Blog"
	},
	"max_blocks": "2",
	"settings": [
		{
			"type": "card_header",
			"label": {
				"zh_CN": "设置",
				"en_US": "Settings"
			}
		},
		{
			"type": "card_select",
			"label": {
				"zh_CN": "标题对齐方式",
				"en_US": "Title alignment"
			},
			"default": "left",
			"id": "text_align",
			"option": [
				{
					"value": "left",
					"label": {
						"zh_CN": "居左",
						"en_US": "To the left"
					}
				},
				{
					"value": "center",
					"label": {
						"zh_CN": "居中",
						"en_US": "In the center"
					}
				},
				{
					"value": "right",
					"label": {
						"zh_CN": "居右",
						"en_US": "To the right"
					}
				}
			]
		},
		{
			"type": "card_input",
			"label": {
				"zh_CN": "标题",
				"en_US": "Title"
			},
			"id": "block_title",
			"default": ""
		},
		{
			"type": "card_text_editor",
			"label": {
				"zh_CN": "简短描述",
				"en_US": "Short description"
			},
			"id": "block_detail",
			"default": ""
		},
		{
			"type": "card_input",
			"label": {
				"zh_CN": "查看更多",
				"en_US": "See more"
			},
			"id": "more_text",
			"default": "Read More"
		}
	],
	"blocks": [
		{
			"name": {
				"zh_CN": "博客",
				"en_US": "Blog"
			},
			"type": "blogs-item",
			"settings": [
				{
					"type": "card_blog",
					"id": "blog",
					"label": {
						"zh_CN": "博客",
						"en_US": "Blog"
					},
					"default": {
						"id": "",
						"title": ""
					}
				}
			]
		}
	],
	"default": {
		"settings": {
			"block_title": "Blogs",
			"block_detail": "",
			"more_text": "READ MORE",
			"text_align": "left"
		},
		"blocks": [
			{
				"blog": {
					"id": "",
					"title": ""
				},
				"block_type": "blogs-item"
			},
			{
				"blog": {
					"id": "",
					"title": ""
				},
				"block_type": "blogs-item"
			},
			{
				"blog": {
					"id": "",
					"title": ""
				},
				"block_type": "blogs-item"
			}
		]
	}
}
{% endschema %}